//
// Created by Lenovo on 2020/10/20.
//

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll cal(ll x)
{
    if(x==0) return 0;
    ll n = (x-1)/192+1;
    ll ans = n*(1+(192*(n-1)+1))/2;
    return ans;


}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll l,r;
        cin>>l>>r;
        ll ans = cal(r)-cal(l-1);
        cout<<ans<<endl;
    }
}